<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.xwtech.framework.pub.commons.PermissionTree"%>
<%@ include file="/admin/jsp/taglibs.jsp"%>
<html>
	<head>
		<%@ include file="/admin/jsp/header.jsp"%>
		<%@ include file="/framework/jsp/validation.jsp"%>
		<script language="javascript" src="/framework/js/tips_alert.js"></script>
		<%@ include file="/framework/jsp/tree.jsp"%>
		<%@ include file="/framework/jsp/tablesorter.jsp"%>
	</head>
	<body onload="loadTree();">
		<%
			String treeXML = "<?xml version='1.0' encoding='GB18030'?><tree id='0></tree>";
			PermissionTree permissionTree = (PermissionTree)request.getAttribute("permissionTree");
			treeXML = permissionTree.getPermissionTreeXml();
		%>
		<table width="98%" border="0" align="center" cellpadding="3" cellspacing="0">
			<tr>
				<td class="page-title">
					<img src="../images/page_title.gif" alt="title" width="17" height="12" align="absmiddle">
					&nbsp;&nbsp; 组织管理 » 角色管理 » 角色修改
				</td>
			</tr>
		</table>
		<br>
		<form id="form" action="/admin/jsp/roleMgr.do?method=updRole" method="post" onsubmit="return check()">
			<input type="hidden" name="roleId" id="roleId" value="<c:out value='${resultObject.roleId}'/>">
			<input type="hidden" name="permissions" id="permissions">
			<table width="50%" border="0" align="center" cellpadding="5" cellspacing="0">
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>角色名称
					</td>
					<td>
						<input name="roleName" class="required max-length-25" type="text" id="roleName" size="30"
							value="<c:out value='${resultObject.roleName}'/>">
						<a href="#"><img src="../images/help.gif" tips="角色名称，25字以内" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						角色描述
					</td>
					<td>
						<input name="roleDesc" class="max-length-100" type="text" id="roleDesc" size="30" value="<c:out value='${resultObject.roleDesc}'/>">
						<a href="#"><img src="../images/help.gif" tips="角色的描述信息，100字以内" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="top">
						<font color="red">*</font>角色权限
					</td>
					<td>
							<input type="hidden" id="permissionTreeXml" name="permissionTreeXml" value='<%=treeXML%>' />
							<div id="permissionTree" style="height: 300px; width: 250px;"></div>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						角色状态
					</td>
					<td>
						<input name="status" class="validate-one-required" type="radio" id="roleDesc" value="1">
						有效
						<input name="status" class="validate-one-required" type="radio" id="roleDesc" value="0">
						无效
					</td>
				</tr>

				<tr>
					<td align="center" valign="middle" colspan="2">
						<input type="submit" class="short-button" value="提  交" />
						<input type="button" class="short-button" value="返  回" onclick="window.location='/admin/jsp/roleMgr.do?method=queryRole'" />
					</td>
				</tr>
			</table>

		</form>
	</body>
	<script>
		new Validation('form',{immediate:true});
		//new Validation('form');
		checkedRadio('status','<c:out value="${resultObject.status}"/>');
		
		//加载权限树
		var tree;
		function loadTree(){
			tree = new dhtmlXTreeObject("permissionTree","100%","90%",0);
			tree.setImagePath("/framework/plugins/dhtmlxTree/codebase/imgs/csh_yellowbooks/");
			var treeXml = document.getElementById("permissionTreeXml").value;
			tree.enableTreeLines(true);
			tree.enableCheckBoxes(true);
			tree.enableThreeStateCheckboxes(true);
			
			tree.loadXMLString(treeXml);
		}
		//获取树型选中节点
		function getAllChecked()
		{
			var checkedStr = tree.getAllCheckedBranches();
			return checkedStr;
		}
		//提交前页面检验
		function check()
		{
			var permissionStr = getAllChecked();
			if((permissionStr == undefined) || (permissionStr == null) || (permissionStr == ""))
			{
				alert("请选择权限信息");
				return false;
			}
			else
			{
				$("#permissions").val(permissionStr);
			}
			return true;
		}
	</script>
</html>